package com.wj.rpsm.user.mapper;

import com.wj.rpsm.user.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


/**
 * @author WeiJin
 * @version 1.0
 */
@Repository
public interface UserMapper {

    /**
     * 根据id修改用户状态
     * @param user
     * @return
     */
    @Update("update `user` set user_status = #{user_status} where userid = #{userid}")
    int updateStatusById(User user);

    /**
     * 根据id获取用户信息
     * @param id
     * @return
     */
    @Select("select account, username, user_type, userid, gender, age, user_status, user_avatar ,user_roomid, idcard " +
            "from `user` where userid = #{id}")
    User getById(Integer id);

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    Integer updateInfo(User user);

    /**
     * 登录
     * @param account
     * @param password
     * @return
     */
    User login(String account, String password);

    /**
     * 根据用户账号查询用户
     * @param account
     * @return
     */
    @Select("select * from user where account = #{account}")
    User getUserByAccount(@Param("account") String account);


}
